package O3.workflow;

public class LoopFor {

    public static void main(String[] args) {
        int sum = 0;
        for (int i=1; i<=100; i++) {
            sum = sum + i;
        }
        System.out.println(sum);

        int[] ns = { 1, 4, 9, 16, 25 };
        int result = 0;
        for (int i=0; i<ns.length; i++) {
            System.out.println("i = " + i + ", ns[i] = " + ns[i]);
            result += ns[i];
        }
        System.out.println("sum = " + result);

        for (int n:ns){
            System.out.println(n);
        }

        System.out.println("************");

        for(int j=ns.length-1;j>=0;j--){
            System.out.println(ns[j]);
        }

        System.out.println("************");
        int summary = 0;
        for(int t=0;t<ns.length;t++){
            summary += ns[t];
        }
        System.out.println(summary);
        System.out.println("************");
        double pi = 0;
        for (int m=1; m<10000; m++){
            double tc = 1 / (Math.pow(-1, m-1)*(2*m-1));
            pi += tc;
        }
        System.out.println(pi*4);

    }
}
